﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Tanks.Contracts;

namespace TanksGame
{
    class MapObject:IGameObject
    {
        public Texture2D Texture { get; private set; }

        public int X { get; private set; }

        public int Y { get; private set; }

        public int Width { get; private set; }

        public int Height { get; private set; }

        public MapItemType ItemType { get; private set; }

        public bool Alive;

        private int _currentFrame;

        public MapObject(MapItemType type, int x, int y, int size , Texture2D texture)
        {
            Texture = texture;
            ItemType = type;
            X = x*18;
            Y = y*18;
            Width = 18*size;
            Height = 18*size;
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            if (Texture!=null)
            spriteBatch.Draw(Texture,new Rectangle(X,Y,Width,Height),Color.White );
        }

        virtual public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (Texture!= null)
            spriteBatch.Draw(Texture, new Rectangle(X, Y, Width, Height),
                             new Rectangle(_currentFrame * 234, 0, 234, 234),
                             Color.White);
          
        }

        public void Update(GameTime gameTime)
        {
            _currentFrame = gameTime.ElapsedGameTime.Seconds%200;
            if (_currentFrame>0)
                Alive =false;
            return;
        }
    }
}
